package com.ctl.shardingsphere.controller;

import com.ctl.shardingsphere.model.Device;
import com.ctl.shardingsphere.model.query.DeviceQuery;
import com.ctl.shardingsphere.service.DeviceService;
import com.ctl.shardingsphere.service.impl.DeviceServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @Classname UserController
 * @Description 用户测试控制类
 * @Author ctl
 * @Date 2019-06-28 17:36
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/device")
public class DeviceController {

    @Autowired(required = false)
    private DeviceService deviceService;
    @Autowired(required = false)
    private DeviceServiceImpl deviceServiceImpl;
    @RequestMapping("/select")
    public List<Device> select(DeviceQuery query) {
        return deviceService.getDeviceList(query);
    }

    @RequestMapping("/getById")
    public Object getById(DeviceQuery query) {
        return deviceServiceImpl.getById(query.getId());
    }

    @GetMapping("/insert")
    public Boolean insert(Device device) {
        return deviceService.save(device);
    }

}